<template>
    <div class="brother2">
        <button @click="sendMsg">点击触发Brother1组件的自定义事件，并发送数据</button>
        <button @click="unbind">点击解绑receive-msg自定义事件</button>
    </div>
</template>

<script>
export default {
    name: 'Brother2',
    methods: {
        sendMsg() {
            this.$bus.$emit('receive-msg', '这是Brother2组件发送过来的数据~');
        },
        unbind() {
            this.$bus.$off('receive-msg');
        }
    }
}
</script>

<style scoped>
button {
    margin-right: 5px;
}
</style>